package com.cr.admin.business.application.dao.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cr.admin.business.application.dao.mapper.ApplicationMapper;
import com.cr.admin.business.application.dao.repository.ApplicationRepository;
import com.cr.admin.business.application.pojo.entity.Application;
import com.cr.admin.business.application.pojo.param.ApplicationFollowParam;
import com.cr.admin.business.application.pojo.query.ApplicationQuery;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ApplicationRepositoryImpl implements ApplicationRepository {
    @Autowired
    private ApplicationMapper applicationMapper;
    @Override
    public List<Application> selectApplication(ApplicationQuery applicationQuery) {
        QueryWrapper<Application> queryWrapper = new QueryWrapper<>();

        if(applicationQuery.getName()!=null){
            queryWrapper.like("name",applicationQuery.getName());
        }
        if(applicationQuery.getPhone()!=null){
            queryWrapper.like("phone",applicationQuery.getPhone());
        }
        if(applicationQuery.getCityName()!=null){
            queryWrapper.like("cityId",applicationQuery.getCityName());
        }
        if(applicationQuery.getCarType()!=null){
            queryWrapper.like("carType",applicationQuery.getCarType());
        }


        return applicationMapper.selectList(queryWrapper);
    }

    @Override
    public void followById(Application application) {
        applicationMapper.updateById(application);
    }

    @Override
    public Application selectById(Long id) {
        return applicationMapper.selectById(id);
    }

    @Override
    public void deleteByIds(List<Long> ids) {
        applicationMapper.deleteBatchIds(ids);
    }
}
